<?php  if (!defined('PATH_HD')) exit('No direct script access allowed');
	class BackupControl extends control{
		public function back(){
			$this->display();
		}
		function __success(){
        $this->success("操作成功","reback");
    }
		// 修改备份配置项
		public function backup(){
			$backup =include './config/backup.php';
			$databack=$_POST;
			$backupconfig=array_merge($backup,$databack);
			$str = "<?php if(!defined('PATH_HD'))exit;\nreturn ".var_export($backupconfig,true).";\n?>";
         	if(@file_put_contents("./config/backup.php", $str)){
            	// $this->success("修改配置项成功 ",'runback');
            	go('runback');
         	}else{
             $this->error("配置文件不能写，请修改文件权限");
         	}
			// Backup::backup(array(
			// 	'url'=>'index',
			// 	'dir'=>"./backup/".date("Ymdhis"),
			// 	'row'=>int()$_POST['row'];
			// 	'step'=>
			// 	));
		}
		// 执行备份
		public function runback(){
			$data=include './config/backup.php';
			Backup::backup(array(
				'url'=>'index',
				'dir'=>"./backup/".date("Ymdhis"),
				'row'=>$data['row'],
				'step_time'=>$data['step_time']
				));
		}
		// 还原备份显示视图
		public function reback(){
			$tree = dir::tree("./backup");
			$this->assign('tree',$tree);
			$this->display();
		}
		//执行还原备份
		function recovery(){
           $dir = $_GET['dir'];
           backup::recovery(array(
               "dir" => "./backup/".$dir,
               "url" => "__success",
               "step_time"=>0,
             	)
           );
    	}  
		//删除备份
		public function del(){
			$dir = $_GET['dir'];
			echo $dir;die;
		}
	}

?>